#
#   Nebula TEKDEMO
#
#   Light Anim
#   Two colord point lights, changing position + color over time
#
#   created:    15-May-99   Bernd Beyreuther
#   upd.:       08-Nov-2000
#
#   (C) 1999 RADON LABS   Beyreuther, Weissflog, Flemming GbR
#   (C) COPYRIGHT 2000 RADONLABS GMBH
#
#
#   This proc generates a lenseflare object
#
def genLenseFlare():
	flare=new ('n3dnode','flare')
	sel ('flare')
	f=new ('nlenseflare','f')
	sel ('f')
	f.beginflares(6)
	f.setblindcolor(0.000000,0.000000,0.000000,0.000000)
	f.setflaresizeat(0,0.200000)
	f.setflaresizeat(1,0.30000)
	f.setflaresizeat(2,0.400000)
	f.setflaresizeat(3,0.20000)
	f.setflaresizeat(4,0.40000)
	f.setflaresizeat(5,0.20000)
	f.setflareposat(0,0.500000)
	f.setflareposat(1,1.200000)
	f.setflareposat(2,1.600000)
	f.setflareposat(3,2.000000)
	f.setflareposat(4,2.500000)
	f.setflareposat(5,3.00000)
	f.setflarecolorat(0,0.3,0.0,0.7,1)
	f.setflarecolorat(1,0.0,0.3,0.4,1)
	f.setflarecolorat(2,0.1,0.3,0.0,1)
	f.setflarecolorat(3,0.4,0.0,0.0,1)
	f.setflarecolorat(4,0.3,0.1,0.3,1)
	f.setflarecolorat(5,0.5,0.5,0.5,1)
	f.endflares()
	sel ('..')
	shader=new ('nshadernode','shader')
	sel ('shader')
	shader.setrenderpri(0)
	shader.setnumstages(1)
	shader.setcolorop(0,"mul tex prev" )
	shader.setalphaop(0,"nop")
	shader.setconst(0,0.000000,0.000000,0.000000,0.000000)
	shader.begintunit(0)
	shader.setaddress("wrap","wrap")
	shader.setminmagfilter("linear_mipmap_nearest","linear")
	shader.settexcoordsrc("uv0")
	shader.setenabletransform(0)
	shader.txyz(0.000000,0.000000,0.000000)
	shader.rxyz(0.000000,0.000000,0.000000)
	shader.sxyz(1.000000,1.000000,1.000000)
	shader.endtunit()
	shader.setdiffuse(0.000000,0.000000,0.000000,0.000000)
	shader.setemissive(0.000000,0.000000,0.000000,0.000000)
	shader.setambient(0.000000,0.000000,0.000000,0.000000)
	shader.setlightenable(0)
	shader.setalphaenable(1)
	shader.setzwriteenable(0)
	shader.setfogenable(0)
	shader.setalphablend("one","one")
	shader.setzfunc("lessequal")
	shader.setcullmode("ccw")
	shader.setcolormaterial("material")
	sel ('..')
	tex=new ('ntexarraynode','tex')
	sel ('tex')
	tex.settexture(0,"../bmp/flare.bmp","none")
	tex.setgenmipmaps(0,1)
	tex.setgenmipmaps(1,1)
	tex.setgenmipmaps(2,1)
	tex.setgenmipmaps(3,1)
	sel ('..')
	sel ('..')
	
	
sel ('/usr/scene')
execfile ('routines.py')
# Switching off the ambient light
amb=new ('nlightnode','amb')
amb.settype('ambient')
amb.setcolor(0,0,0,0)
# The two lightsources rotating
dlight=new ('n3dnode','dlight')
sel ('dlight')
roty=new ('nipol','roty')
sel ('roty')
roty.connect('ry')
roty.addkey1f(0,0)
roty.addkey1f(6,360)
sel ('..')
rotx=new ('nipol','rotx')
sel ('rotx')
rotx.connect('rx')
rotx.addkey1f(0,0)
rotx.addkey1f(7,60)
rotx.addkey1f(13,0)
sel ('..')
light1=plainobject ('light1','../meshes/lampe.n3d','../bmp/marble.bmp')
sel ('light1')
light1.txyz (2,0,2)
light1.sxyz (0.25,0.25,0.25)
shader=sel ('shader')
shader.setambient (0,0,0,0)
shader.setdiffuse (0,0,0,0)
em=new ('nipol','em')
sel ('em')
em.connect('setemissive')
em.addkey4f(0,0,1,1,0)
em.addkey4f(1.5,1,0,0,1)
em.addkey4f(3,0,0,1,1)
em.addkey4f(4,0,1,1,0)
sel ('..')
sel ('..')
lighta=new ('nlightnode','lighta')
sel ('lighta')
lighta.setattenuation(1,0,0)
lighta.settype('point')
lighta.setcolor(0.1,0.5,1,1)
col=new ('nipol','col')
sel ('col')
col.connect('setcolor')
col.addkey4f(0,0,1,1,0)
col.addkey4f(1.5,1,0,0,1)
col.addkey4f(3,0,0,1,1)
col.addkey4f(4,0,1,1,0)
sel ('..')
sel ('..')
#genLenseFlare ()
sel ('..')
light2=plainobject ('light2','../meshes/lampe.n3d','../bmp/marble.bmp')
sel ('light2')
light2.txyz (-2,0,-2)
light2.sxyz (0.25,0.25,0.25)
shader=sel ('shader')
shader.setdiffuse (0,0,0,0)
shader.setambient (0,0,0,0)
em=new ('nipol','em')
sel ('em')
em.connect('setemissive')
em.addkey4f(0,1,1,0,0)
em.addkey4f(1.5,1,1,1,1)
em.addkey4f(2,0,1,0,1)
em.addkey4f(6,1,1,0,0)
sel ('..')
sel ('..')
li2=new ('nlightnode','li2')
sel ('li2')
li2.setattenuation(1,0,0)
li2.settype('point')
li2.setcolor(0.1,0.5,1,1)
col=new ('nipol','col')
sel ('col')
col.connect('setcolor')
col.addkey4f(0,1,1,0,0)
col.addkey4f(1.5,1,1,1,1)
col.addkey4f(2,0,1,0,1)
col.addkey4f(6,1,1,0,0)
sel ('..')
sel ('..')
sel ('..')
ding=plainobject ('ding','../meshes/nebula.n3d','../bmp/marble.bmp')
sel ('ding')
rotz=new ('nipol','rotz')
sel ('rotz')
rotz.connect('rz')
rotz.addkey1f(0,0)
rotz.addkey1f(10,360)
sel ('..')
rotx=new ('nipol','rotx')
sel ('rotx')
rotx.connect('rx')
rotx.addkey1f(0,360)
rotx.addkey1f(30,0)
sel ('..')
sel ('..')
